package com.lj.queue.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lj.mp.standard.StandardService;
import com.lj.queue.entity.DelayQueueMeta;
import com.lj.queue.param.DelayQueueMetaPageParam;
import com.lj.queue.param.DelayQueueMetaSaveParam;
import com.lj.queue.param.DelayQueueMetaUpdateParam;
import com.lj.queue.result.DelayQueueMetaInfoResult;
import com.lj.queue.result.DelayQueueMetaPageResult;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 延迟队列数据表 服务类
 * </p>
 *
 * @author lj
 * @since 2025-07-17 10:38:03
 */
public interface DelayQueueMetaService extends StandardService<DelayQueueMeta> {

    IPage<DelayQueueMetaPageResult> page(DelayQueueMetaPageParam param);

    DelayQueueMetaInfoResult info(Long id);

    void save(DelayQueueMetaSaveParam param);

    void update(DelayQueueMetaUpdateParam param);

    void delete(List<Long> ids);

    default void updateLastLoadTime(Long id, LocalDateTime time) {
        update(lambdaUpdateWrapper()
                .set(DelayQueueMeta::getLastLoadTime, time)
                .eq(DelayQueueMeta::getId, id));
    }

    default DelayQueueMeta getByQueueName(String queueName) {
        return getOne(lambdaQueryWrapper()
                .eq(DelayQueueMeta::getName, queueName)
                .last("limit 1"));
    }
}
